"""""""""""""""""""""""
""""游戏配置参数文件""""
"""""""""""""""""""""""

import  random
#关卡砖块分布，共有四关
levels = (
    (1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
     1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
     1, 0, 1, 1, 1, 1, 1, 1, 0, 1,
     1, 0, 1, 0, 1, 1, 0, 1, 0, 1,
     1, 0, 0, 1, 1, 1, 1, 0, 0, 1,
     1, 0, 1, 1, 1, 1, 1, 1, 0, 1,
     1, 0, 1, 0, 0, 0, 0, 1, 0, 1,
     1, 0, 1, 1, 1, 1, 1, 1, 0, 1,
     1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
    (2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
     2, 0, 0, 2, 2, 2, 2, 0, 0, 2,
     2, 0, 0, 2, 2, 2, 2, 0, 0, 2,
     2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
     2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
     2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
     2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
     2, 0, 0, 2, 2, 2, 2, 0, 0, 2,
     2, 0, 0, 2, 2, 2, 2, 0, 0, 2,
     2, 2, 2, 2, 2, 2, 2, 2, 2, 2),
    (3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
     3, 3, 0, 0, 0, 0, 0, 0, 3, 3,
     3, 3, 0, 0, 0, 0, 0, 0, 3, 3,
     3, 3, 0, 0, 0, 0, 0, 0, 3, 3,
     3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
     3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
     3, 3, 0, 0, 0, 0, 0, 0, 3, 3,
     3, 3, 0, 0, 0, 0, 0, 0, 3, 3,
     3, 3, 0, 0, 0, 0, 0, 0, 3, 3,
     3, 3, 3, 3, 3, 3, 3, 3, 3, 3),
    (4, 4, 4, 4, 0, 0, 4, 4, 4, 4,
     4, 4, 4, 0, 4, 4, 0, 4, 4, 4,
     4, 4, 0, 4, 4, 4, 4, 0, 4, 4,
     4, 0, 4, 4, 4, 4, 4, 4, 0, 4,
     0, 4, 4, 4, 4, 4, 4, 4, 4, 0,
     4, 0, 4, 4, 4, 4, 4, 4, 0, 4,
     4, 4, 0, 4, 4, 4, 4, 0, 4, 4,
     4, 4, 4, 0, 4, 4, 0, 4, 4, 4,
     4, 4, 4, 4, 0, 0, 4, 4, 4, 4,
     4, 4, 4, 4, 4, 4, 4, 4, 4, 4)
)


def new_level(n):
    if n < 4:
        return levels[n]
    # n 关卡数
    # num_blocks 砖块数目
    tmp = random.randint(1, 16)
    num_blocks = 30 + 4 * n + tmp
    # cur_num当前砖块数目
    cur_num = 0
    # color_block 将赋给砖块的值, 用于Game.py 中上色
    color_block = n % 8 + 1
    map_level = [0] * 100
    radio = (num_blocks * 1.2 / 100) + 1
    for i in range(10):
        for j in range(5):
            k = random.random() * radio  # 随机生成 判断系数
            if (k > 1) & (cur_num < num_blocks):
                idx_1 = 10 * i + j
                idx_2 = 10 * i + 9 - j
                map_level[idx_1] = color_block
                map_level[idx_2] = color_block
                cur_num += 2
    tuple_level = tuple(map_level)
    return tuple_level


#屏幕宽度
sc_width = 600
#屏幕高度
sc_height = 500
# 游戏开始参数
game_active = False
#游戏结束参数
game_over = False
#游戏暂停参数
waiting = True
#游戏分数
score = 0
#生命
lives = 3
#所在关卡
level = 0
#当前小球数目
ball_num = 1

